﻿using AutoMapper;
using DbModel.Models;
using DbModel.ViewModel.Article;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Extensions.AutoMapper
{
    public class ArticleProfile:Profile
    {
        public ArticleProfile()
        {
            CreateMap<CreateArticleInputDto, Article>();
            CreateMap<UpdateArticleInputDto, Article>();
            CreateMap<Article,ArticleDto>();
            CreateMap<Article,ArticleDetailsDto>();

            CreateMap<ArticleComment,ArticleCommentDto>()
                .ForMember(a=>a.UserName,o=>o.MapFrom(x=>x.CreateUser.UserName))
                .ForMember(a=>a.HeadPortrait,o=>o.MapFrom(x=>x.CreateUser.HeadPortrait));

            CreateMap<CreateArticleCommentsInputDto, ArticleComment>();
        }
    }
}
